<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<div id="d1"></div>
<script type="text/javascript">
var count=0;
//开启计时器 每隔一秒修改div的显示内容
var timer=setInterval(function(){
	d1.innerText=count++;
	if(count==5){
		//停止计时器
		clearInterval(timer);
	}
},1000);
</script>
</body>
</html>